<%@ page import="java.io.PrintWriter" %><%--
  Created by IntelliJ IDEA.
  User: 86180
  Date: 2020/6/22
  Time: 21:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>Title</title>
</head>
<body>

<%--逻辑判断如果传过来的Attribute是空的，就是直接访问home，然后判断登录过没有。然后给username赋值--%>
<%
    if((String)request.getAttribute("username")==null){
        Cookie[] c = request.getCookies();

        if(c != null){
            for(int i = 0;i < c.length;i++) {
                if ("username".equals(c[i].getName())) {
                    request.setAttribute("username",c[i].getValue());
                    break;
                }
            }
    }


}%>

<%--判断username是否为空来判断是否能够登录成功--%>
<c:if test="${username ==null}">
        <h1>请重新登录</h1>
    <a href="login.jsp">  返回登录页面</a>
</c:if>

<%--判断username是否为空来判断是否能够登录成功--%>
<c:if test="${username !=null}">
    <h1> 欢迎登录 ${username}</h1>
    <h3> 修改密码</h3>
<%--    对应的接收数据 和传递数据--%>
    <%request.getSession().setAttribute("username",(String)request.getAttribute("username"));%>


    <form action="/testweb_war_exploded/xiugai" method="post">


        新密码<input type="text" name="password">
        <button type="submit">修改</button>
    </form>

    <a href="login.jsp">  退出登录</a>
</c:if>

</body>
</html>
